<?php
// +----------------------------------------------------------------------
// | HYYPHP [ WE CAN DO IT JUST HYYPHP ]
// +----------------------------------------------------------------------
// | Copyright (c) HanSheng All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: HanSheng <164897033@qq.com>
// +----------------------------------------------------------------------
namespace hyyphp;

use hyyphp\template\Action;

class Controller {
    /**
     * 模板对象
     * @var null
     */
    private $tplObj;

    /**
     * 构造方法
     * Controller constructor.
     */
    public function __construct()
    {

    }

	/**
	 * 给模板变量赋值
	 * @param              $tpl_var 变量名称
	 * @param string|array $var     变量值
	 */
    public function assign($tpl_var, $var = '') {
		if(is_null($this->tplObj)) $this->tplObj = new Action();
        $this->tplObj->assign($tpl_var, $var);
    }

    public function fetch($file = '') {
		if(is_null($this->tplObj)) $this->tplObj = new Action();
        if($file == '') {
            $file = strtolower(CONTROLLER_NAME) . '/' . FUNCTION_NAME;
        }
        $this->tplObj->display($file);
    }
}